package com.yygo.model;

import com.yygo.model.enums.*;
import org.hibernate.search.annotations.*;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Entity
@Indexed
@Table(name = "loan_reqeust")
public class LoanRequest extends BaseObject {

    private static final long serialVersionUID = -1567609426462572831L;
    private Long id;
    private String number;
    private String contractNo;
    private String coverNumber;
    private Date requestDate;
    private Date decideDate;
    private Date loanDate;
    private Date auditDate;
    private Dealer dealer;
    private User dealerUser;
    private User auditUser;

    private MaterialAudit materialAudit;
    private MoneyTransferRecord moneyTransferRecord;
    private CommissionTransferRecord commissionTransferRecord;

    private Phase phase = Phase.draft;
    private RequestStatus status = RequestStatus.draft;

    private List<Feedback> feedbackList = new ArrayList();
    private List<Attachment> attachmentList = new ArrayList();
    private List<TalkRecord> talkRecordList = new ArrayList();
    private List<Activity> activities = new ArrayList<>();
    private List<Rule> rules = new ArrayList<>();
    private LoanPerson requestPerson = new LoanPerson();
    private LoanPerson coPerson;
    private LoanPerson dbPerson;

    private CreditQuestionnaire requestPersonCreditQuestionnaire;
    private CreditQuestionnaire coPersonCreditQuestionnaire;
    private CreditQuestionnaire dbPersonCreditQuestionnaire;

    private boolean coLoaned = false;
    private boolean guaranted = false;

    private String urgentContactName1;
    private String urgentContactGender1;
    private String urgentContactTelNo1;
    private String urgentContactRelation1;
    private String urgentContactName2;
    private String urgentContactGender2;
    private String urgentContactTelNo2;
    private String urgentContactRelation2;
    private String urgentContactName3;
    private String urgentContactGender3;
    private String urgentContactTelNo3;
    private String urgentContactRelation3;

    private boolean second;
    private String vehicleBrand;
    private String vehicleSeries;
    private String vehicleModel;
    private float ManufacturerPrice;
    private float price;
    private int loanYears;
    private float loanRate;
    private float downPaymentRate;
    private float downPaymentAmount;
    private float loanAmount;
    private float monthPaymentAmount;
    private float feeRate;
    private double totalReturnAmount;

    private Date vehicleManufactureDate;
    private Date vehiclePurchaseDate;
    private String frameNo;
    private String engineNumber;

    // commerial insurance info
    private String insuranceName;
    private float premiumAmount;
    private float insuranceAmount;
    private Date insureStartDate;
    private Date insureEndDate;
    private String insuranceCoverNo;
    private String invoiceUnit;

    private String bankContractNo;
    private String creditCardNo;

    // ca credit limit info
    private boolean propertyGuarented;
    private float propertyArea;
    private float pricePerSquare;
    private float creditScore;
    private String creditScoreType;
    private float annualMustCost;
    private float xishu;
    private float basicPrice;
    private String calComment;

    private LoanProduct loanProduct;
    private Long loanProductId;

    private String pbocComment;
    private String auditComment;
    private String dealerComment;
    private String singleAuditComment;
    private String singleDealerComment;

    private String addressCert;
    private String incomeCert;
    private String driveCert;
    private String identityCert;

    private boolean theftInsuranceComplete = false;
    private boolean nunuoInsuranceComplete = false;
    private boolean responseInsuranceComplete = false;
    private boolean damageInsuranceComplete = false;
    private boolean contactSigned = false;
    private boolean facePhotoed = false;
    private boolean authorizationSigned = false;
    private boolean invoiceProvided = false;
    private boolean mortgaged = false;
    private boolean lunuoSafe = false;
    private boolean mustInsurance = false;

    private AuditCode auditCode;

    private String salesman;
    private boolean sendback;

    private Prepayment prepayment;

    private boolean canGrab;

    private float policyFee;

    private boolean canPrepay;

    @Transient
    public boolean isCanGrab() {
        return canGrab;
    }

    public void setCanGrab(boolean canGrab) {
        this.canGrab = canGrab;
    }

    @Transient
    public float getPolicyFee() {
        return policyFee;
    }

    public void setPolicyFee(float policyFee) {
        this.policyFee = policyFee;
    }

    @Transient
  public Long getCopyFromRequestId() {
    return copyFromRequestId;
  }

  public void setCopyFromRequestId(Long copyFromRequestId) {
    this.copyFromRequestId = copyFromRequestId;
  }

  private Long copyFromRequestId;

    public LoanRequest() {}

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @DocumentId
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column(name = "number", unique = true, length = 10)
    @Field
    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    @Column(name = "contract_no", unique = true, length = 10)
    @Field
    public String getContractNo() {
        return contractNo;
    }

    public void setContractNo(String contractNo) {
        this.contractNo = contractNo;
    }

    @Column(name = "cover_number")
    @Field
    public String getCoverNumber() {
        return coverNumber;
    }

    public void setCoverNumber(String coverNumber) {
        this.coverNumber = coverNumber;
    }

    @Column(name = "request_date")
    @Fields({
            @Field,
            @Field(name="sorting_name", analyze=Analyze.NO)
    })
    public Date getRequestDate() {
        return requestDate;
    }

    public void setRequestDate(Date requestDate) {
        this.requestDate = requestDate;
    }

    @Column(name = "decide_date")
    public Date getDecideDate() {
        return decideDate;
    }

    public void setDecideDate(Date decideDate) {
        this.decideDate = decideDate;
    }

    @Column(name = "loan_date")
    public Date getLoanDate() {
        return loanDate;
    }

    public void setLoanDate(Date loanDate) {
        this.loanDate = loanDate;
    }

    @Column(name = "audit_date")
    public Date getAuditDate() {
        return auditDate;
    }

    public void setAuditDate(Date auditDate) {
        this.auditDate = auditDate;
    }

    @ManyToOne(cascade = CascadeType.MERGE)
    @JoinColumn(name="dealer_id")
    public Dealer getDealer() {
        return dealer;
    }

    public void setDealer(Dealer dealer) {
        this.dealer = dealer;
    }

    @ManyToOne(cascade = CascadeType.MERGE)
    @JoinColumn(name="dealer_user_id")
    public User getDealerUser() {
        return dealerUser;
    }

    public void setDealerUser(User dealerUser) {
        this.dealerUser = dealerUser;
    }

    @ManyToOne(cascade = CascadeType.MERGE)
    @JoinColumn(name="audit_user_id")
    public User getAuditUser() {
        return auditUser;
    }

    public void setAuditUser(User auditUser) {
        this.auditUser = auditUser;
    }

    @Enumerated(EnumType.STRING)
    @Column(name = "request_status", length = 50)
    @Field(analyze = Analyze.NO)
    public RequestStatus getStatus() {
        return status;
    }

    public void setStatus(RequestStatus status) {
        this.status = status;
    }

    @Enumerated(EnumType.STRING)
    @Column(name = "phase", length = 50)
    @Field(analyze = Analyze.NO)
    public Phase getPhase() {
        return phase;
    }

    public void setPhase(Phase phase) {
        this.phase = phase;
    }

    @OneToOne(mappedBy = "loanRequest", cascade = CascadeType.ALL)
    public MaterialAudit getMaterialAudit() {
        return materialAudit;
    }

    public void setMaterialAudit(MaterialAudit materialAudit) {
        this.materialAudit = materialAudit;
    }

    @OneToOne(mappedBy = "loanRequest")
    public MoneyTransferRecord getMoneyTransferRecord() {
        return moneyTransferRecord;
    }

    public void setMoneyTransferRecord(MoneyTransferRecord moneyTransferRecord) {
        this.moneyTransferRecord = moneyTransferRecord;
    }

    @OneToOne(mappedBy = "loanRequest")
    public CommissionTransferRecord getCommissionTransferRecord() {
        return commissionTransferRecord;
    }

    public void setCommissionTransferRecord(CommissionTransferRecord commissionTransferRecord) {
        this.commissionTransferRecord = commissionTransferRecord;
    }

    @OneToMany(mappedBy = "loanRequest", cascade=CascadeType.ALL)
    public List<Feedback> getFeedbackList() {
        return feedbackList;
    }

    public void setFeedbackList(List<Feedback> feedbackList) {
        this.feedbackList = feedbackList;
    }

    @OneToMany(mappedBy = "loanRequest", cascade=CascadeType.ALL)
    public List<Attachment> getAttachmentList() {
        return attachmentList;
    }

    public void setAttachmentList(List<Attachment> attachments) {
        this.attachmentList = attachments;
    }

    @OneToMany(mappedBy = "loanRequest", cascade=CascadeType.ALL)
    public List<TalkRecord> getTalkRecordList() {
        return talkRecordList;
    }

    public void setTalkRecordList(List<TalkRecord> talkRecordList) {
        this.talkRecordList = talkRecordList;
    }

    @OneToMany(mappedBy = "loanRequest", cascade=CascadeType.ALL)
    public List<Activity> getActivities() {
        return activities;
    }

    public void setActivities(List<Activity> activities) {
        this.activities = activities;
    }

    @OneToMany(mappedBy = "loanRequest", cascade=CascadeType.ALL)
    public List<Rule> getRules() {
        return rules;
    }

    public void setRules(List<Rule> rules) {
        this.rules = rules;
    }

    @Column(name = "urgent_contact_name", length = 50)
    public String getUrgentContactName1() {
        return urgentContactName1;
    }

    public void setUrgentContactName1(String urgentContactName1) {
        this.urgentContactName1 = urgentContactName1;
    }

    @Column(name = "urgent_contact_gender", length = 50)
    public String getUrgentContactGender1() {
        return urgentContactGender1;
    }

    public void setUrgentContactGender1(String urgentContactGender1) {
        this.urgentContactGender1 = urgentContactGender1;
    }

    @Column(name = "urgent_contact_gender2", length = 50)
    public String getUrgentContactGender2() {
        return urgentContactGender2;
    }

    public void setUrgentContactGender2(String urgentContactGender2) {
        this.urgentContactGender2 = urgentContactGender2;
    }

    @Column(name = "urgent_contact_gender3", length = 50)
    public String getUrgentContactGender3() {
        return urgentContactGender3;
    }

    public void setUrgentContactGender3(String urgentContactGender3) {
        this.urgentContactGender3 = urgentContactGender3;
    }

    @Column(name = "urgent_contact_no", length = 20)
    public String getUrgentContactTelNo1() {
        return urgentContactTelNo1;
    }

    public void setUrgentContactTelNo1(String urgentContactTelNo1) {
        this.urgentContactTelNo1 = urgentContactTelNo1;
    }

    @Column(name = "urgent_contact_relation", length = 50)
    public String getUrgentContactRelation1() {
        return urgentContactRelation1;
    }

    public void setUrgentContactRelation1(String urgentContactRelation1) {
        this.urgentContactRelation1 = urgentContactRelation1;
    }

    @Column(name = "urgent_contact_name2", length = 50)
    public String getUrgentContactName2() {
        return urgentContactName2;
    }

    public void setUrgentContactName2(String urgentContactName2) {
        this.urgentContactName2 = urgentContactName2;
    }

    @Column(name = "urgent_contact_tel_no2", length = 50)
    public String getUrgentContactTelNo2() {
        return urgentContactTelNo2;
    }

    public void setUrgentContactTelNo2(String urgentContactTelNo2) {
        this.urgentContactTelNo2 = urgentContactTelNo2;
    }

    @Column(name = "urgent_contact_relation2", length = 50)
    public String getUrgentContactRelation2() {
        return urgentContactRelation2;
    }

    public void setUrgentContactRelation2(String urgentContactRelation2) {
        this.urgentContactRelation2 = urgentContactRelation2;
    }

    @Column(name = "urgent_contact_name3", length = 50)
    public String getUrgentContactName3() {
        return urgentContactName3;
    }

    public void setUrgentContactName3(String urgentContactName3) {
        this.urgentContactName3 = urgentContactName3;
    }

    @Column(name = "urgent_contact_tel_no3", length = 50)
    public String getUrgentContactTelNo3() {
        return urgentContactTelNo3;
    }

    public void setUrgentContactTelNo3(String urgentContactTelNo3) {
        this.urgentContactTelNo3 = urgentContactTelNo3;
    }

    @Column(name = "urgent_contact_relation3", length = 50)
    public String getUrgentContactRelation3() {
        return urgentContactRelation3;
    }

    public void setUrgentContactRelation3(String urgentContactRelation3) {
        this.urgentContactRelation3 = urgentContactRelation3;
    }

    @Column(name="is_second")
    public boolean isSecond() {
        return second;
    }

    public void setSecond(boolean second) {
        this.second = second;
    }

    @Column(name = "vehicle_brand", length = 50)
    public String getVehicleBrand() {
        return vehicleBrand;
    }

    public void setVehicleBrand(String vehicleBrand) {
        this.vehicleBrand = vehicleBrand;
    }
    @Column(name = "vehicle_series", length = 50)
    public String getVehicleSeries() {
        return vehicleSeries;
    }

    public void setVehicleSeries(String vehicleSeries) {
        this.vehicleSeries = vehicleSeries;
    }
    @Column(name = "vehicle_model", length = 50)
    public String getVehicleModel() {
        return vehicleModel;
    }

    public void setVehicleModel(String vehicleModel) {
        this.vehicleModel = vehicleModel;
    }

    @Column(name = "manufacturer_price", columnDefinition = "float default 0.0")
    public float getManufacturerPrice() {
        return ManufacturerPrice;
    }

    public void setManufacturerPrice(float manufacturerPrice) {
        ManufacturerPrice = manufacturerPrice;
    }

    @Column(name = "price", columnDefinition = "float default 0.0")
    public float getPrice() {
        return price;
    }

    public void setPrice(float price) {
        this.price = price;
    }

    @Column(name = "loan_years", columnDefinition = "int default 0")
    public int getLoanYears() {
        return loanYears;
    }

    public void setLoanYears(int loanYears) {
        this.loanYears = loanYears;
    }

    @Column(name = "loan_rate", columnDefinition = "float default 0.0")
    public float getLoanRate() {
        return loanRate;
    }

    public void setLoanRate(float loanRate) {
        this.loanRate = loanRate;
    }

    @Column(name = "down_payment_rate", columnDefinition = "float default 0.0")
    public float getDownPaymentRate() {
        return downPaymentRate;
    }

    public void setDownPaymentRate(float downPaymentRate) {
        this.downPaymentRate = downPaymentRate;
    }

    @Column(name = "credit_score", columnDefinition = "float default 0.0")
    public float getCreditScore() {
        return creditScore;
    }
    @Column(name="credit_score_type")
    public String getCreditScoreType() {
        return creditScoreType;
    }

    public void setCreditScoreType(String creditScoreType) {
        this.creditScoreType = creditScoreType;
    }

    public void setCreditScore(float creditScore) {
        this.creditScore = creditScore;
    }

    @Column(name = "down_payment_amount", columnDefinition = "float default 0.0")
    public float getDownPaymentAmount() {
        return downPaymentAmount;
    }

    public void setDownPaymentAmount(float downPaymentAmount) {
        this.downPaymentAmount = downPaymentAmount;
    }

    @Column(name = "loan_amount", columnDefinition = "float default 0.0")
    public float getLoanAmount() {
        return loanAmount;
    }

    public void setLoanAmount(float loanAmount) {
        this.loanAmount = loanAmount;
    }

    @Column(name = "month_payment_amount", columnDefinition = "float default 0")
    public float getMonthPaymentAmount() {
        return monthPaymentAmount;
    }

    public void setMonthPaymentAmount(float monthPaymentAmount) {
        this.monthPaymentAmount = monthPaymentAmount;
    }
    @Column(name = "fee_rate", columnDefinition = "float default 0.0")
    public float getFeeRate() {
        return feeRate;
    }

    public void setFeeRate(float feeRate) {
        this.feeRate = feeRate;
    }

    @Column(name="total_return_amount", columnDefinition = "double default 0")
    public double getTotalReturnAmount() {
        return totalReturnAmount;
    }

    public void setTotalReturnAmount(double totalReturnAmount) {
        this.totalReturnAmount = totalReturnAmount;
    }

    @Column(name="vehicle_manufacture_date")
    public Date getVehicleManufactureDate() {
        return vehicleManufactureDate;
    }

    public void setVehicleManufactureDate(Date vehicleManufactureDate) {
        this.vehicleManufactureDate = vehicleManufactureDate;
    }

    @Column(name="vehicle_purchase_date")
    public Date getVehiclePurchaseDate() {
        return vehiclePurchaseDate;
    }

    public void setVehiclePurchaseDate(Date vehiclePurchaseDate) {
        this.vehiclePurchaseDate = vehiclePurchaseDate;
    }

    @Column(name="frame_no")
    public String getFrameNo() {
        return frameNo;
    }

    public void setFrameNo(String frameNo) {
        this.frameNo = frameNo;
    }

    @Column(name="engine_number")
    public String getEngineNumber() {
        return engineNumber;
    }

    public void setEngineNumber(String engineNumber) {
        this.engineNumber = engineNumber;
    }

    @Column(name="insurance_name")
    public String getInsuranceName() {
        return insuranceName;
    }

    public void setInsuranceName(String insuranceName) {
        this.insuranceName = insuranceName;
    }

    @Column(name="premium_amount")
    public float getPremiumAmount() {
        return premiumAmount;
    }

    public void setPremiumAmount(float premiumAmount) {
        this.premiumAmount = premiumAmount;
    }

    @Column(name="insurance_amount")
    public float getInsuranceAmount() {
        return insuranceAmount;
    }

    public void setInsuranceAmount(float insuranceAmount) {
        this.insuranceAmount = insuranceAmount;
    }

    @Column(name="insure_start_date")
    public Date getInsureStartDate() {
        return insureStartDate;
    }

    public void setInsureStartDate(Date insureStartDate) {
        this.insureStartDate = insureStartDate;
    }

    @Column(name="insure_end_date")
    public Date getInsureEndDate() {
        return insureEndDate;
    }

    public void setInsureEndDate(Date insureEndDate) {
        this.insureEndDate = insureEndDate;
    }

    @Column(name="insurance_cover_no")
    public String getInsuranceCoverNo() {
        return insuranceCoverNo;
    }

    public void setInsuranceCoverNo(String insuranceCoverNo) {
        this.insuranceCoverNo = insuranceCoverNo;
    }

    @Column(name="invoice_unit")
    public String getInvoiceUnit() {
        return invoiceUnit;
    }

    public void setInvoiceUnit(String invoiceUnit) {
        this.invoiceUnit = invoiceUnit;
    }

    @Column(name="bank_contract_no")
    public String getBankContractNo() {
        return bankContractNo;
    }

    public void setBankContractNo(String bankContractNo) {
        this.bankContractNo = bankContractNo;
    }

    @Column(name="credit_card_no")
    public String getCreditCardNo() {
        return creditCardNo;
    }

    public void setCreditCardNo(String creditCardNo) {
        this.creditCardNo = creditCardNo;
    }

    @Column(name="property_guarented")
    public boolean isPropertyGuarented() {
        return propertyGuarented;
    }

    public void setPropertyGuarented(boolean propertyGuarented) {
        this.propertyGuarented = propertyGuarented;
    }

    @Column(name="property_area")
    public float getPropertyArea() {
        return propertyArea;
    }

    public void setPropertyArea(float propertyArea) {
        this.propertyArea = propertyArea;
    }

    @Column(name="price_per_square")
    public float getPricePerSquare() {
        return pricePerSquare;
    }

    public void setPricePerSquare(float pricePerSquare) {
        this.pricePerSquare = pricePerSquare;
    }

    @Column(name="annual_must_cost")
    public float getAnnualMustCost() {
        return annualMustCost;
    }

    public void setAnnualMustCost(float annualMustCost) {
        this.annualMustCost = annualMustCost;
    }

    @Column(name="xishu")
    public float getXishu() {
        return xishu;
    }

    public void setXishu(float xishu) {
        this.xishu = xishu;
    }

    @Column(name="basic_price")
    public float getBasicPrice() {
        return basicPrice;
    }

    public void setBasicPrice(float basicPrice) {
        this.basicPrice = basicPrice;
    }

    @Column(name="cal_comment")
    public String getCalComment() {
        return calComment;
    }

    public void setCalComment(String calComment) {
        this.calComment = calComment;
    }

    @Column(name = "co_loaned")
    public boolean isCoLoaned() {
        return coLoaned;
    }

    public void setCoLoaned(boolean coLoaned) {
        this.coLoaned = coLoaned;
    }

    @Column(name = "guaranted")
    public boolean isGuaranted() {
        return guaranted;
    }

    public void setGuaranted(boolean guaranted) {
        this.guaranted = guaranted;
    }


    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name="req_person_id")
    @ContainedIn
    @IndexedEmbedded
    public LoanPerson getRequestPerson() {
        return requestPerson;
    }

    public void setRequestPerson(LoanPerson requestPerson) {
        this.requestPerson = requestPerson;
    }

    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name="co_person_id")
    @ContainedIn
    @IndexedEmbedded
    public LoanPerson getCoPerson() {
        return coPerson;
    }

    public void setCoPerson(LoanPerson coPerson) {
        this.coPerson = coPerson;
    }

    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name="db_person_id")
    @ContainedIn
    @IndexedEmbedded
    public LoanPerson getDbPerson() {
        return dbPerson;
    }

    public void setDbPerson(LoanPerson dbPerson) {
        this.dbPerson = dbPerson;
    }

    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name="req_person_questionnaire_id")
    public CreditQuestionnaire getRequestPersonCreditQuestionnaire() {
        return requestPersonCreditQuestionnaire;
    }

    public void setRequestPersonCreditQuestionnaire(CreditQuestionnaire requestPersonCreditQuestionnaire) {
        this.requestPersonCreditQuestionnaire = requestPersonCreditQuestionnaire;
    }

    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name="co_person_questionnaire_id")
    public CreditQuestionnaire getCoPersonCreditQuestionnaire() {
        return coPersonCreditQuestionnaire;
    }

    public void setCoPersonCreditQuestionnaire(CreditQuestionnaire coPersonCreditQuestionnaire) {
        this.coPersonCreditQuestionnaire = coPersonCreditQuestionnaire;
    }

    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name="db_person_questionnaire_id")
    public CreditQuestionnaire getDbPersonCreditQuestionnaire() {
        return dbPersonCreditQuestionnaire;
    }

    public void setDbPersonCreditQuestionnaire(CreditQuestionnaire dbPersonCreditQuestionnaire) {
        this.dbPersonCreditQuestionnaire = dbPersonCreditQuestionnaire;
    }

    @ManyToOne
    @JoinColumn(name="loan_prod_id")
    public LoanProduct getLoanProduct() {
        return loanProduct;
    }

    public void setLoanProduct(LoanProduct loanProduct) {
        this.loanProduct = loanProduct;
    }

    @Transient
    public Long getLoanProductId() {
        return loanProductId;
    }

    public void setLoanProductId(Long loanProductId) {
        this.loanProductId = loanProductId;
    }

    @Column(name="audit_comment")
    @Lob
    public String getAuditComment() {
        return auditComment;
    }

    public void setAuditComment(String auditComment) {
        this.auditComment = auditComment;
    }

    @Column(name="dealer_comment")
    @Lob
    public String getDealerComment() {
        return dealerComment;
    }

    public void setDealerComment(String dealerComment) {
        this.dealerComment = dealerComment;
    }

    @Transient
    public String getSingleAuditComment() {
        return singleAuditComment;
    }

    public void setSingleAuditComment(String singleAuditComment) {
        this.singleAuditComment = singleAuditComment;
    }

    @Transient
    public String getSingleDealerComment() {
        return singleDealerComment;
    }

    public void setSingleDealerComment(String singleDealerComment) {
        this.singleDealerComment = singleDealerComment;
    }

    @Column(name="pboc_comment")
    @Lob
    public String getPbocComment() {
        return pbocComment;
    }

    public void setPbocComment(String pbocComment) {
        this.pbocComment = pbocComment;
    }

    @Column(name="address_cert", length = 20)
    public String getAddressCert() {
        return addressCert;
    }

    public void setAddressCert(String addressCert) {
        this.addressCert = addressCert;
    }

    @Column(name="income_cert", length = 20)
    public String getIncomeCert() {
        return incomeCert;
    }

    public void setIncomeCert(String incomeCert) {
        this.incomeCert = incomeCert;
    }

    @Column(name="drive_cert", length = 20)
    public String getDriveCert() {
        return driveCert;
    }

    public void setDriveCert(String driveCert) {
        this.driveCert = driveCert;
    }

    @Column(name="identity_cert", length = 20)
    public String getIdentityCert() {
        return identityCert;
    }

    public void setIdentityCert(String identityCert) {
        this.identityCert = identityCert;
    }

    @Column(name="theft_insurance")
    public boolean isTheftInsuranceComplete() {
        return theftInsuranceComplete;
    }

    public void setTheftInsuranceComplete(boolean theftInsuranceComplete) {
        this.theftInsuranceComplete = theftInsuranceComplete;
    }

    @Column(name="nunuo_insurance")
    public boolean isNunuoInsuranceComplete() {
        return nunuoInsuranceComplete;
    }

    public void setNunuoInsuranceComplete(boolean nunuoInsuranceComplete) {
        this.nunuoInsuranceComplete = nunuoInsuranceComplete;
    }

    @Column(name="response_insurance")
    public boolean isResponseInsuranceComplete() {
        return responseInsuranceComplete;
    }

    public void setResponseInsuranceComplete(boolean responseInsuranceComplete) {
        this.responseInsuranceComplete = responseInsuranceComplete;
    }

    @Column(name="damage_insurance")
    public boolean isDamageInsuranceComplete() {
        return damageInsuranceComplete;
    }

    public void setDamageInsuranceComplete(boolean damageInsuranceComplete) {
        this.damageInsuranceComplete = damageInsuranceComplete;
    }

    @Column(name="contact_signed")
    public boolean isContactSigned() {
        return contactSigned;
    }

    public void setContactSigned(boolean contactSigned) {
        this.contactSigned = contactSigned;
    }

    @Column(name="face_photoed")
    public boolean isFacePhotoed() {
        return facePhotoed;
    }

    public void setFacePhotoed(boolean facePhotoed) {
        this.facePhotoed = facePhotoed;
    }

    @Column(name="authorization_signed")
    public boolean isAuthorizationSigned() {
        return authorizationSigned;
    }

    public void setAuthorizationSigned(boolean authorizationSigned) {
        this.authorizationSigned = authorizationSigned;
    }

    @Column(name="invoice_provided")
    public boolean isInvoiceProvided() {
        return invoiceProvided;
    }

    public void setInvoiceProvided(boolean invoiceProvided) {
        this.invoiceProvided = invoiceProvided;
    }

    @Column(name="mortgaged")
    public boolean isMortgaged() {
        return mortgaged;
    }

    public void setMortgaged(boolean mortgaged) {
        this.mortgaged = mortgaged;
    }

    @Column(name="lunuo_safe")
    public boolean isLunuoSafe() {
        return lunuoSafe;
    }

    public void setLunuoSafe(boolean lunuoSafe) {
        this.lunuoSafe = lunuoSafe;
    }
    @Column(name="must_insurance")
    public boolean isMustInsurance() {
        return mustInsurance;
    }

    public void setMustInsurance(boolean mustInsurance) {
        this.mustInsurance = mustInsurance;
    }

    @Enumerated(EnumType.STRING)
    @Column(name = "audit_code", length = 20)
    public AuditCode getAuditCode() {
        return auditCode;
    }

    public void setAuditCode(AuditCode auditCode) {
        this.auditCode = auditCode;
    }

    @Column(name="salesman")
    public String getSalesman() {
        return salesman;
    }

    public void setSalesman(String salesman) {
        this.salesman = salesman;
    }

    @Column(name="is_send_back")
    public boolean isSendback() {
        return sendback;
    }

    public void setSendback(boolean sendback) {
        this.sendback = sendback;
    }

    @Column(name="prepay_enabled")
    public boolean isCanPrepay() {
        return canPrepay;
    }

    public void setCanPrepay(boolean canPrepay) {
        this.canPrepay = canPrepay;
    }

    @OneToOne(mappedBy = "loanRequest")
    public Prepayment getPrepayment() {
        return prepayment;
    }

    public void setPrepayment(Prepayment prepayment) {
        this.prepayment = prepayment;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        LoanRequest loanRequest = (LoanRequest) o;

        if (requestPerson.getId().equals(loanRequest.getId())) {
            return true;
        }

        return false;
    }

    public int hashCode() {
        int result;
        result = (requestPerson.getName() != null ? requestPerson.getName().hashCode() : 0);
        result = 31 * result + (requestPerson.getIdType() != null ? requestPerson.getIdType().hashCode() : 0);
        result = 57 * result + (requestPerson.getIdNo() != null ? requestPerson.getIdNo().hashCode() : 0);
        return result;
    }

    public String toString() {
        return "LoanRequest{" +
                "number=" + number +
                ", requestUser='" + requestPerson.getName() + '\'' +
                ", idType='" + requestPerson.getIdType() + '\'' +
                ", idNo='" + requestPerson.getIdNo() + '\'' +
                '}';
    }

    @Transient
    public String getVehicleInfo() {
        StringBuffer buffer = new StringBuffer();
        buffer.append(vehicleBrand).append(" - ")
                .append(vehicleSeries).append(" - ")
                .append(vehicleModel);
        return buffer.toString();
    }

}
